package com.jdbc.lesson03;

import com.jdbc.utils.JdbcUtils;

import java.sql.*;

public class TestSelect {
    public static void main(String[] args) {
        Connection conn = null;
        PreparedStatement st = null;
        ResultSet rs = null;
        try {
            conn = JdbcUtils.getConnection();
            String sql = "select * from `users` where `id` = ?";
            st = conn.prepareStatement(sql);
            st.setInt(1,4);
            rs = st.executeQuery();
            while(rs.next()){
                System.out.println("id:"+rs.getObject("id"));
                System.out.println("NAME:"+rs.getObject("NAME"));
                System.out.println("PASSWORD:"+rs.getObject("PASSWORD"));
                System.out.println("email:"+rs.getObject("email"));
                System.out.println("birthday:"+rs.getObject("birthday"));
                System.out.println("-------------------------");
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
//        catch (ParseException e) {
//            e.printStackTrace();
//        }
        finally {
            JdbcUtils.release(conn,st,rs);
        }
    }
}
